package com.block.risk.factory;

import com.block.common.util.ApplicationContextUtil;
import com.block.risk.enums.RiskTypeEnum;
import com.block.risk.service.IRiskService;
import com.block.risk.service.type.*;

import java.util.HashMap;
import java.util.Map;

public class RiskTypeFactory {

    private static Map<String, Class<? extends IRiskService>> serviceMap = new HashMap<>();
    static {
        serviceMap.put(RiskTypeEnum.YUJU.getValue(), YujuRiskService.class);
        serviceMap.put(RiskTypeEnum.ZAIYANG.getValue(), ZaiYangRiskService.class);
        serviceMap.put(RiskTypeEnum.ZAIYANG2.getValue(), ZaiYang2RiskService.class);
        serviceMap.put(RiskTypeEnum.ZAIYANG3.getValue(), ZaiYang3RiskService.class);

    }

    public static IRiskService getService(String filterKey){
        if (serviceMap.containsKey(filterKey)){
            Class<? extends IRiskService> aClass = serviceMap.get(filterKey);
            return ApplicationContextUtil.getBean(aClass);
        }
        return ApplicationContextUtil.getBean(DefaultRiskService.class);
    }

}
